package top.waikin.aspect.controller;

import org.springframework.web.bind.annotation.*;
import top.waikin.aspect.bean.Demo;
import top.waikin.aspect.service.DemoService;

import javax.annotation.Resource;

/**
 * @author WaiKin
 * @date 2022/11/29
 */
@RestController
@RequestMapping("/demo")
public class DemoController {
  @Resource DemoService demoService;

  @PostMapping
  public Long create(@RequestBody Demo demo) {
    return demoService.create(demo);
  }

  @DeleteMapping("/{id}")
  public void delete(@PathVariable Long id) {
    demoService.delete(id);
  }

  @PutMapping("/{id}")
  public void update(@PathVariable Long id, Demo demo) {
    demoService.update(id, demo);
  }

  @GetMapping("/{id}")
  public Demo getById(@PathVariable Long id) {
    return demoService.getById(id);
  }
}
